<template>
    <el-container>
        <SideMenu/>
        <el-container direction="vertical">
            <TopHeader/>
            <el-main>
                <router-view></router-view>
            </el-main>
        </el-container>
    </el-container>
</template>

<!-- 引入两个孩子(侧边栏和导航栏) -->
<script setup>
import TopHeader from '../components/mainbox/TopHeader.vue';
import SideMenu from '../components/mainbox/SideMenu.vue';
import { onMounted, onUnmounted } from 'vue';
import { checkTokenValidity } from '../util/auth';

// 定时检查token有效性
let tokenCheckInterval = null;

onMounted(() => {
    // 每15分钟检查一次token有效性
    tokenCheckInterval = setInterval(async () => {
        await checkTokenValidity();
    }, 15 * 60 * 1000); // 15分钟
});

onUnmounted(() => {
    // 组件卸载时清除定时器
    if (tokenCheckInterval) {
        clearInterval(tokenCheckInterval);
    }
});
</script>

<style lang="scss" scoped>
.el-main{
    overflow: auto;
    height: calc(100vh - 60px);
}
</style>